home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Resources / Chat & Communication / Digsby build 37 / digsby_setup.exe / lib / gui / pref / noobcontactlayoutpanel.pyo (.txt) < prev    next >
Encoding:
Python Compiled Bytecode  |  2008-10-13  |  4.8 KB  |  111 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyo (Python 2.5)
  3.  
  4. import wx
  5. from cgui import SimplePanel
  6. from gui.pref.prefcontrols import mark_pref, get_pref
  7.  
  8. class NoobContactLayoutPanel(wx.Panel):
  9.     
  10.     def __init__(self, parent):
  11.         wx.Panel.__init__(self, parent)
  12.         self.Sizer = wx.BoxSizer(wx.VERTICAL)
  13.         self.grid = wx.FlexGridSizer(2, 3)
  14.         self.grid.AddGrowableRow(1, 1)
  15.         self.Sizer.Add(self.grid, 0, wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_CENTER_HORIZONTAL)
  16.         skin = skin
  17.         import gui
  18.         g = skin.get
  19.         icons = g('AppDefaults.ez.icons')
  20.         items = self.items = [
  21.             LayoutItem(self, icons.one, dict(show_extra = True, extra_info = 'both', show_buddy_icon = True, buddy_icon_pos = 'left', buddy_icon_size = 32, show_status_icon = True, status_icon_pos = 'bleft', show_service_icon = True, service_icon_pos = 'bright')),
  22.             LayoutItem(self, icons.two, dict(show_extra = True, extra_info = 'both', show_buddy_icon = True, buddy_icon_pos = 'right', buddy_icon_size = 32, show_status_icon = True, status_icon_pos = 'bleft', show_service_icon = True, service_icon_pos = 'bright')),
  23.             LayoutItem(self, icons.three, dict(show_extra = True, extra_info = 'both', show_buddy_icon = True, buddy_icon_pos = 'right', buddy_icon_size = 32, show_status_icon = True, status_icon_pos = 'left', show_service_icon = True, service_icon_pos = 'bright')),
  24.             LayoutItem(self, icons.four, dict(show_extra = True, extra_info = 'idle', show_buddy_icon = False, show_status_icon = True, status_icon_pos = 'right', show_service_icon = True, service_icon_pos = 'left')),
  25.             LayoutItem(self, icons.five, dict(show_extra = True, extra_info = 'idle', show_buddy_icon = False, show_status_icon = True, status_icon_pos = 'left', show_service_icon = True, service_icon_pos = 'right')),
  26.             LayoutItem(self, icons.six, dict(show_extra = True, extra_info = 'idle', show_buddy_icon = False, show_status_icon = True, status_icon_pos = 'left', show_service_icon = False))]
  27.         []([ (item, 0) for item in items ])
  28.         self.selection = None
  29.         for item in items:
  30.             for key in item.prefdict:
  31.                 if item.prefdict[key] != get_pref('buddylist.layout.%s' % key):
  32.                     break
  33.                     continue
  34.                 []
  35.             else:
  36.                 break
  37.         
  38.  
  39.     
  40.     def SetSelection(self, item):
  41.         newselection = item
  42.         print newselection
  43.         oldselection = self.selection
  44.         if oldselection:
  45.             oldselection.selected = False
  46.             oldselection.Refresh()
  47.         
  48.         self.selection = newselection
  49.         newselection.selected = True
  50.         self.Refresh()
  51.         for key in newselection.prefdict:
  52.             value = newselection.prefdict[key]
  53.             mark_pref('buddylist.layout.%s' % key, value)
  54.         
  55.  
  56.  
  57.  
  58. class LayoutItem(SimplePanel):
  59.     
  60.     def __init__(self, parent, bitmap, prefdict):
  61.         SimplePanel.__init__(self, parent, wx.FULL_REPAINT_ON_RESIZE)
  62.         self.prefdict = prefdict
  63.         self.bitmap = bitmap
  64.         self.MinSize = self.bitmap.Size + (16, 16)
  65.         self.selected = False
  66.         self.Bind(wx.EVT_PAINT, self.OnPaint)
  67.         self.Bind((wx.EVT_MOTION,), (lambda e: self.Refresh()))
  68.         self.Bind(wx.EVT_LEAVE_WINDOW, self.OnMouseLeave)
  69.         self.Bind(wx.EVT_LEFT_DOWN, self.OnLeftDown)
  70.         self.Bind(wx.EVT_LEFT_UP, self.OnLeftUp)
  71.  
  72.     
  73.     def OnPaint(self, event):
  74.         dc = wx.BufferedPaintDC(self)
  75.         rect = wx.RectS(self.Size)
  76.         dc.Brush = wx.WHITE_BRUSH
  77.         dc.Pen = wx.TRANSPARENT_PEN
  78.         dc.DrawRectangleRect(rect)
  79.         if rect.Contains(self.ScreenToClient(wx.GetMousePosition())):
  80.             dc.Brush = wx.Brush(wx.Color(238, 239, 255))
  81.             dc.Pen = wx.Pen(wx.Color(128, 128, 255))
  82.             dc.DrawRoundedRectangleRect(rect, 4)
  83.             if wx.GetMouseState().LeftDown():
  84.                 rect2 = rect.Deflate(5, 5)
  85.                 dc.Pen = wx.TRANSPARENT_PEN
  86.                 dc.Brush = wx.Brush(wx.Color(200, 200, 255))
  87.                 dc.DrawRectangleRect(rect2)
  88.             
  89.         
  90.         if self.selected:
  91.             rect2 = rect.Deflate(4, 4)
  92.             dc.Pen = wx.TRANSPARENT_PEN
  93.             dc.Brush = wx.Brush(wx.Color(128, 128, 255))
  94.             dc.DrawRectangleRect(rect2)
  95.         
  96.         dc.DrawBitmap(self.bitmap, 8, 8, True)
  97.  
  98.     
  99.     def OnLeftUp(self, event):
  100.         self.Parent.SetSelection(self)
  101.  
  102.     
  103.     def OnLeftDown(self, event):
  104.         self.Refresh()
  105.  
  106.     
  107.     def OnMouseLeave(self, event):
  108.         self.Refresh()
  109.  
  110.  
  111.